package org.niu.twopointer;

import java.lang.reflect.Array;
import java.util.*;

public class TwoSum {
    public int[] twoSum (int[] numbers, int target) {
        // write code here
        Map<Integer,Integer> mp = new HashMap<>();
        int[] ans = new int[2];
        for(int i = 0;i < numbers.length;i++){
            if(mp.get(target-numbers[i])!=null){
                ans[0] = mp.get(target-numbers[i]);
                ans[1] = i+1;}
            mp.put(numbers[i],i+1);
        }
        return ans;
    }
}
